package com.zhonghui.procurementManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.procurementManagement.domain.ProcurementBanner;
import com.zhonghui.procurementManagement.service.IProcurementBannerService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 采购管理系统-轮播图Controller
 * 
 * @author zhonghui
 * @date 2023-11-28
 */

@RestController
@Anonymous
@RequestMapping("/procurementManagement/PmBanner")
public class ProcurementBannerController extends BaseController
{
    @Autowired
    private IProcurementBannerService procurementBannerService;

    /**
     * 查询采购管理系统-轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProcurementBanner procurementBanner)
    {
        startPage();
        List<ProcurementBanner> list = procurementBannerService.selectProcurementBannerList(procurementBanner);
        return getDataTable(list);
    }

    /**
     * 导出采购管理系统-轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:export')")
    @Log(title = "采购管理系统-轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProcurementBanner procurementBanner)
    {
        List<ProcurementBanner> list = procurementBannerService.selectProcurementBannerList(procurementBanner);
        ExcelUtil<ProcurementBanner> util = new ExcelUtil<ProcurementBanner>(ProcurementBanner.class);
        util.exportExcel(response, list, "采购管理系统-轮播图数据");
    }

    /**
     * 获取采购管理系统-轮播图详细信息
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(procurementBannerService.selectProcurementBannerById(id));
    }

    /**
     * 新增采购管理系统-轮播图
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:add')")
    @Log(title = "采购管理系统-轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProcurementBanner procurementBanner)
    {
        return toAjax(procurementBannerService.insertProcurementBanner(procurementBanner));
    }

    /**
     * 修改采购管理系统-轮播图
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:edit')")
    @Log(title = "采购管理系统-轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProcurementBanner procurementBanner)
    {
        return toAjax(procurementBannerService.updateProcurementBanner(procurementBanner));
    }

    /**
     * 删除采购管理系统-轮播图
     */
    @PreAuthorize("@ss.hasPermi('procurementManagement:PmBanner:remove')")
    @Log(title = "采购管理系统-轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(procurementBannerService.deleteProcurementBannerByIds(ids));
    }
}
